//学号：202102820
//姓名：王寰宇
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;
//server
public class Receiver{
    public static void main(String[] args) throws Exception{
        long begin=System.currentTimeMillis();
        ServerSocket serverSocket = new ServerSocket(9000);
        Socket socket = serverSocket.accept();
        InputStream is = socket.getInputStream();
        File file=new File("D://Receive//receives.qlv");


        FileOutputStream fos = new FileOutputStream(file);
        byte[] buffer = new byte[1024];



        int len;
        while ((len = is.read(buffer)) != -1) {
            fos.write(buffer,0,len);
        }
        fos.close();
        is.close();
        socket.close();
        serverSocket.close();
        long end=System.currentTimeMillis();
        System.out.println("程序运行的时间为："+(end-begin)+"ms");
    }
}